package com.fakesmoker.aidawnda.model.vo;

import cn.hutool.json.JSONUtil;
import com.fakesmoker.aidawnda.model.entity.Team;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 队伍视图类
 *
 * @author 修改后作者
 */
@Data
public class TeamVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 队伍id
     */
    private Long id;

    /**
     * 队伍标题
     */
    private String name;

    /**
     * 队伍描述
     */
    private String description;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 创建用户 id
     */
    private Long userId;

    /**
     * 创建用户信息
     */
    private UserVO user;

    /**
     * 已加入队伍的用户信息
     */
    private List<UserVO> users;

    /**
     * 封装类转对象
     *
     * @param teamVO
     * @return
     */
    public static Team voToObj(TeamVO teamVO) {
        if (teamVO == null) {
            return null;
        }
        Team team = new Team();
        BeanUtils.copyProperties(teamVO, team);
        return team;
    }

    /**
     * 对象转封装类
     *
     * @param team
     * @return
     */
    public static TeamVO objToVo(Team team) {
        if (team == null) {
            return null;
        }
        TeamVO teamVO = new TeamVO();
        BeanUtils.copyProperties(team, teamVO);
        return teamVO;
    }
}